<?php
class Control_Uploadbutton extends QUI_Control_Abstract
{
	function render()
	{
		$out = Q::control('textbox', $this->id(), $this->attrs())->render();
		$upurl = url('admin::interface/uploadeditor');
		$out .= <<<EOT
<input type="button" class='uploadbutton' value="上传" id="b{$this->id()}">
<script type="text/javascript">
$('#b{$this->id()}').upload({
	action: '{$upurl}',
	onComplete: function(data) {
		var obj = eval('('+ data +')');
		if(obj.err == '' && obj.msg.url)
		{
			$('#{$this->id()}').val(obj.msg.url.substr(1));
		}else{
			alert(obj.err);
		}
	}
});
</script>
EOT;
		return $out;
	}
}